home *** CD-ROM | disk | FTP | other *** search
/ Palm Utilities / Palm_Utilities_CD-ROM_2001_2001.iso / files / utils text / MakeDocJ 3.3 / MakeDocJ.exe / Source / BookMark.java < prev    next >
Encoding:
Java Source  |  2000-05-23  |  2.0 KB  |  94 lines

  1. /*
  2.  * BookMark.java
  3.  *
  4.  * Copyright 2000 by BRiSK Software,
  5.  * 8702 Switzer Road, Overland Park, KS 66214
  6.  * All rights reserved.
  7.  *
  8.  * This software is the confidential and proprietary information
  9.  * of BRiSK Software. ("Confidential Information").
  10.  * You shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with BRiSK Software.
  13.  *
  14.  * $Id$
  15.  */
  16.  
  17. import java.io.*;
  18.  
  19. /**
  20.  * <code>BookMark</code> class is used to read/write PilotDoc bookmark records
  21.  * @author Jeffrey A. Krzysztow
  22.  * @author Pat Beirne
  23.  * @version 1.1
  24.  */
  25. public class BookMark {
  26.     /**
  27.      * the name of the bookmark
  28.      * @since 1.0
  29.      */
  30.     public String name = "";     // 16 Bytes    Bookmark name
  31.  
  32.     /**
  33.      * offset into PilotDoc for this bookmark
  34.      * @since 1.0
  35.      */
  36.     public int fileOffset = -1;    // 4 DWord    file offset
  37.                                 // 20 bytes bookmark
  38.  
  39.     /**
  40.      * The size of the BookMark in bytes
  41.      * @returns the number of bytes in the BookMark
  42.      * @since 1.0
  43.      */
  44.     public static int getSize() {
  45.         return(20);
  46.     }
  47.  
  48.     /**
  49.      * Reads the BookMark from the DataInput
  50.      * @param the DataInput to read from
  51.      * @since 1.0
  52.      */
  53.     public void read(DataInput di) throws IOException {
  54.         byte[] b = new byte[16];
  55.         di.readFully(b);
  56.         name = new String(b);
  57.         int i = name.indexOf('\0');
  58.         if(i >= 0) {
  59.             name = name.substring(0, i);
  60.         }
  61.         fileOffset = di.readInt();
  62.     }
  63.  
  64.     /**
  65.      * Writes the BookMark to the DataInput
  66.      * @param the DataInput to write to
  67.      * @since 1.0
  68.      */
  69.     public void write(DataOutput out) throws IOException {
  70.         byte[] b = new byte[16];
  71.         byte[] bName = name.getBytes();
  72.         for(int x=0; x < b.length; x++) {
  73.             if(x < bName.length) {
  74.                 b[x] = bName[x];
  75.             }
  76.             else {
  77.                 b[x] = 0;
  78.             }
  79.         }
  80.         out.write(b);
  81.         out.writeInt(fileOffset);
  82.     }
  83.  
  84.     /**
  85.      * override Object.toString()
  86.      * @since 1.0
  87.      */
  88.     public String toString() {
  89.         return ">> BookMark <<\nname = `" + name
  90.             + "`\nfileOffset = " + fileOffset;
  91.     }
  92. }
  93.  
  94.